﻿<?php
include '../inc/db.php';
$user_name = @$_POST['user_name'];
$smsid = '';
$CUR_TIME = date("Y-m-d H:i:s",time());
$sql = "SELECT * from `zy_sms`,`zy_sms_body` where zy_sms.bodyid = zy_sms_body.bodyid and `to_id` = '".$user_name."' and `read` = '0' and `sendtime` <= '".$CUR_TIME."' order by `sendtime` limit 0,1";
$query = mysql_query($sql,$db);
$row = mysql_fetch_array($query);

if($row != ''){
	$sql = "UPDATE `zy_sms` SET `read` = '1' WHERE `id` = ".$row['id'];
	mysql_query($sql,$db);
	$success = true;
	$toid = $row['sender'];
}else{
	$success = false;
	$toid = '';	
}
$dateatter = array("success"=>$success,"toName"=>$toid,"mType"=>'邮件');
echo json_encode($dateatter);
?>
